#include<bits/stdc++.h>
using namespace std;
const int N=100005,M=10000007;
struct node{
    int l,r;
}a[N];
int T,n,m,L,V,ans,sum,p[N];
inline bool cmp(node a,node b){
    if(a.l==b.l)return a.r<b.r;
    return a.l<b.l;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d%d",&n,&m,&L,&V);
        ans=sum=0;
        for(int i=1;i<=n;i++){
            int d,v,q;
            scanf("%d%d%d",&d,&v,&q);
            if(v<V){
                if(q<=0){
                    a[i].l=M;
                    a[i].r=M;
                }
                else{
                    int x=d,fz=V*V-v*v;
                        x+=fz/2/q+1;
                    if(x>L){
                        a[i].l=M;
                        a[i].r=M;
                    }
                    else
                    {
                        a[i].l=x;
                        a[i].r=L;
                    }
                }

            }
            else if(v==V){
                    if(q<=0){
                        a[i].l=M;
                        a[i].r=M;
                    }
                    else{
                        a[i].l=d+1;
                        a[i].r=L;
                    }
            }
            else{
                if(q>=0){
                    a[i].l=d;
                    a[i].r=L;
                }
                else{
                    int fz=v*v-V*V,x;
                    q=-q;
                    if(fz%(2*q)==0)
                        x=d+fz/(2*q)-1;
                    else
                    x=d+fz/(2*q);
                    a[i].l=d;
                    if(x>L)
                    a[i].r=L;
                    else
                    a[i].r=x;
                }
            }
        }
        sort(a+1,a+1+n,cmp);
        for(int i=1;i<=m;i++)
        scanf("%d",&p[i]);
        sort(p+1,p+1+m);
        p[m+1]=M;
        sum=0;
        int minn=M,j=1;
        for(int i=1;i<=m;i++){
            if(a[j].l>p[i])continue;
            while(a[j].l<=p[i]&&j<=n){
                if(a[j].r>=p[i])sum++;
                else
                    a[j].l=a[j].r=M;
                j++;
            }
            if(j>n)break;
        }
        sort(a+1,a+1+n,cmp);
        j=1;
        while(a[n].l>L)n--;
        for(int i=1;i<=m;i++){
            if(a[j].l>p[i])
                continue;
            while(a[j].l<=p[i]&&j<=n){
                minn=min(minn,a[j].r);
                j++;
            }
            if(minn<p[i+1]){
                ans++;
                minn=M;
            }
            else j--;
            if(j>n)break;
        }
        printf("%d %d\n",sum,m-ans);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
